package com.xilihui.xlh.core.app;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.squareup.leakcanary.RefWatcher;
import com.trello.rxlifecycle.components.support.RxFragment;
import com.umeng.analytics.MobclickAgent;

import butterknife.ButterKnife;

public class BaseCompatFragment extends RxFragment {

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        ButterKnife.bind(this,view);
    }

    @Override
    public void onResume() {
        super.onResume();
        MobclickAgent.onPageStart(getClass().getSimpleName() + " " + getTag());
    }

    @Override
    public void onPause() {
        super.onPause();
        MobclickAgent.onPageEnd(getClass().getSimpleName() + " " + getTag());
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        // LeakCanary 监听 Fragment 的内存泄漏
        RefWatcher refWatcher = BaseApplication.getRefWatcher(getActivity());
        refWatcher.watch(this);
    }
}
